<?php
/** Zend_Controller_Action */
require_once 'Zend/Controller/Action.php';
require_once 'Zend/Log.php';
require_once 'Zend/Log/Writer/Stream.php';

class ErrorController extends Zend_Controller_Action
{
    public function errorAction()
    {
        $errors = $this->_getParam('error_handler');
        $exception = $errors->exception;
        
        switch ($errors->type) {
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
                // 404 error -- controller or action not found
                $this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');

                // ... get some output to display...
                break;
            default:
                // application error; display error page, but don't change
                // status code
        
                // ...
        
                // Log the exception:
                $log = new Zend_Log(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../tmp/logs/error.log'));
                $log->debug($exception->getMessage() . "\n" .  $exception->getTraceAsString());
                break;
        }
        
        $this->view->error = $exception->getMessage() . "\n" .  $exception->getTraceAsString();
    }
}